package com.zack.designPattern.command;

public class AddCommand implements Command {

	private Counter counter;

	private int add;
	
	private int addCount;
	
	public AddCommand(Counter counter, int add){
		this.counter = counter;
		this.add = add;
	}
	@Override
	public void excute() {
		counter.add(add);
		addCount++;

	}

	@Override
	public void undo() {
		if(addCount-->0){
			counter.sub(add);
		}else{
			System.out.println("no undo");
		}

	}

}
